<template>
<div>
  <criteria-paged :model="model" v-ref:cp>
    <criteria partial='criteria'  @condition-changed='search' v-ref:criteria>
      <div novalidate partial>
        <table>
          <tr>
            <td>标题:</td>
              <td><input type="text"  id="f_title" class="form-control" v-model="model.f_title" v-on:keyup.enter="search"
               id="f_title" condition="f_title like '%{}%'" ></td>
          </tr>
          <tr>
            <td>下发日期从:</td>
            <td><datepicker id="f_start"
              :value.sync="model.f_start"
              :disabled-days-of-Week="[]"
              :format="'yyyy-MM-dd'"
              v-model="model.f_start"  condition="f_time >= '{}'"></datepicker></td>
          </tr>
          <tr>
            <td>
            至:
          </td>
          <td>
              <datepicker id="f_end"
              :value.sync="model.f_end"
              :disabled-days-of-Week="[]"
              :format="'yyyy-MM-dd'"
              v-model="model.f_end"  condition=" f_time <= '{} 23:59:59'"></datepicker>
            </td>
          </tr>
          <tr>
          <td>
            分公司：
          </td>
          <td>
              <v-select :value.sync="$parent.$parent.model.f_division"
              :options='$parent.$parent.f_divisions'
              placeholder='请选择子公司'
                close-on-select clear-button></v-select>
          </td>
            </tr>
            <tr>
              <td colspan="2">
          <button type="button" class="btn btn-success width-80" @click="search()">
             <span class="glyphicon glyphicon-search"></span> 查询
          </button>
        </td>
        </tr>
      </table>
      </div>
    </criteria>
    <data-grid :model="model" partial='list' v-ref:grid>
      <template partial='head'>
        <tr>
          <th>标    题</th>
          <th>下发时间</th>
          <th>分公司</th>
        </tr>
      </template>
      <template partial='body'>
        <tr>
          <td>{{row.f_title}}</td>
          <td>{{row.f_time}}</td>
          <td>{{row.f_subcompany}}</td>
        </tr>
      </template>
    </data-grid>
  </criteria-paged>
</div>
</template>

<script>
import { PagedList } from 'vue-client'
import Vue from 'vue'
import AppData from '../../stores/AppData'
export default {
  title: '公告查询',
  data () {
    let model = new PagedList('rs/sql/公告查询', 20, {f_subcompany: 'this.f_division[0]'})
    model.f_division = [Vue.f_subcompany]
    return {
      model: model
      // f_divisions: Vue.f_subcompany != '' ? [{label: Vue.f_subcompany, value: Vue.f_subcompany}]: this.$getParams('安检系统用子公司', [{label:'请选择分公司',value:''}])
    }
  },
  computed: {
    f_divisions () {
      // return this.$refs.cp.$refs.grid.selected
      return [{label: '全部', value: ''}, ...AppData.getParam('分公司')]
    }
  }
}
</script>
